/**
 * 申请使用界面上部分表单
 */
var DbServiceDetailInfoDlg = {
    data: {
        id: "",
        department: "",
        dbName: "",
        userId: "",
        username: "",
        password: "",
        servicetype: "",
        system: "",
        details: "",
        standard: "",
        state: "",
        spState: "",
        open: "",
        effectiveTime: "",
        remarks: "",
        revision: "",
        createdBy: "",
        createdTime: "",
        updatedBy: "",
        updatedTime: ""
    }
};

/**
 * 申请下半部分表单
 */

var DbContentapprovalInfoDlg = {
    data: {
        id: "",
        serviceid: "",
        userId: "",
        department: "",
        content: "",
        system: "",
        servicetype: "",
        standard: "",
        details: "",
        state: "",
        remarks: "",
        revision: "",
        createdBy: "",
        createdTime: "",
        updatedBy: "",
        updatedTime: ""
    }
};

layui.use(['form', 'admin', 'ax', 'laydate', 'upload', 'formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;


    //获取表单上部信息并填充表单
    var ajax = new $ax(Feng.ctxPath + "/databaseListKh/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('dbServicelistForm', result.data);
    // console.log(result.data)

    $(function () {
        getUser();
    })

    //为下部表单赋值
    function getUser(){
        //申请的serviceid
        $("#serviceid").attr("value",result.data.id)
        //申请的服务类型
        $("#servicetype").attr("value",result.data.servicetype)
        //申请的使用规范
        // $("#standard").attr("value",result.data.standard)
        $.get(Feng.ctxPath + "/databaseListKh/getUser",function (obj) {
            // console.log(obj)
            //发起申请用户的部门
            $("#dept").attr("value",obj.data.deptName);
            //发起申请的userId
            $("#userId").attr("value",obj.data.id);
        })
    }



    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        // console.log(data)
        var ajax = new $ax(Feng.ctxPath + "/interfaceapproval/addItem", function (data) {
            Feng.success("添加成功！");
            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);
            //关掉对话框
            admin.closeThisDialog();
            // parent.location.reload();
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });


});